package com.better.frontend.service.suggest;

import com.better.common.base.ServiceResponse;
import com.better.common.mongo.model.SpringDataPageable;
import com.better.frontend.Iservice.suggest.UserSuggestService;
import com.better.frontend.domain.suggest.UserSuggest;
import com.better.frontend.repository.suggest.UserSuggestRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2018/1/24.
 */
@Service
public class UserSugggestServiceImp implements UserSuggestService {
    @Autowired
    private UserSuggestRepository userSuggestRepository;

    @Override
    public UserSuggest save(UserSuggest userSuggest) {
        return userSuggestRepository.save(userSuggest);
    }

    @Override
    public List<UserSuggest> listByCondition(UserSuggest userSuggest) {
        return userSuggestRepository.findAll();
    }

    @Override
    public Page<UserSuggest> findPageByCondition(UserSuggest userSuggest,Integer pagesSize,Integer pageNo) {
        Pageable pageable= new SpringDataPageable(pageNo, pagesSize);
        return  userSuggestRepository.findAll(Example.of(userSuggest),pageable);
    }
}
